package com.shamar.blog.enums;


import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author JiWen
 * @time 2020/4/02 14:22
 */
public enum ClearDirectionTypeEnum {
    ABROAD(1, "跨境清分"),
    DOMESTIC(2, "境内清分"),

    ;

    ClearDirectionTypeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private int code;
    private String desc;


    public static ClearDirectionTypeEnum getByCode(int code) {
        for (ClearDirectionTypeEnum anEnum : ClearDirectionTypeEnum.values()) {
            if (anEnum.getCode() == code) {
                return anEnum;
            }
        }
        return null;
    }

    public boolean check(int code) {
        return this.code==code;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }


    public static Map<String, String> toMap() {
        Map<String, String> map = new LinkedHashMap<>();
        for (ClearDirectionTypeEnum value : values()) {
            map.put(String.valueOf(value.code), value.desc);
        }
        return map;
    }
}
